/**
 * This file is part of Wireless TransFer.
 *
 *   Wireless TransFer is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *	
 *   Wireless TransFer is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with Wireless TransFer.  If not, see <http://www.gnu.org/licenses/>.
 *	 
 *	 Copyright (C) 2011
 *   @author christofferP
 */
package com.wirelesstransfer.connection;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.wirelesstransfer.AsyncTasks.UpdateClientStatus;

public class TransferData implements ITransferData {
	
	private List<File> files;
	private int currentFile;
	private UpdateClientStatus update;
	
	public TransferData(List<File> files){
		this.files = new ArrayList<File>(files);
		this.currentFile = -1;
	}
	
	public synchronized List<File> getReceivedFiles() {
		if(currentFile < 1)
			return null;
		return files.subList(0, currentFile);
	}

	public synchronized List<File> getRemainingFiles() {
		if(currentFile >= files.size()-1)
			return null;
		return files.subList(currentFile+1, files.size());
	}

	public synchronized File getCurrentFile() {
		if(currentFile < 0)
			return null;
		if(currentFile >= files.size())
			return null;
		return files.get(currentFile);
	}

	public synchronized List<File> getFiles() {
		return files;
	}

	public synchronized boolean nextFile() {
		
		
		if(currentFile < 0){
			currentFile++;
			System.err.println("first file " + currentFile);
		}
		else if (currentFile >= files.size()){
			System.err.println("no files " + currentFile);

			return false;
		}
		else {
			currentFile++;			
			System.err.println("more files " + currentFile);
		}
		update = new UpdateClientStatus();
		update.execute("update", "update");
		
		return true;
	}
}
